import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tabBarActive: +sessionStorage.getItem("tabBarActive") || 0
  },
  mutations: {
    SET_TABBAR_ACTIVE: (state, index) => {
      state.tabBarActive = index
      sessionStorage.setItem("tabBarActive", index)
    },
  },
  actions: {
    setTabBarActive({ commit }, index) {
      commit("SET_TABBAR_ACTIVE", index)
    }
  },
  getters: {
    tabBarActive: state => state.tabBarActive
  }
})
